package servlet;


import dao.UserDao;
import dao.impl.UserDaoImpl;
import pojo.Users;
import service.impl.UserServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class UserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserDao userDao =  new UserDaoImpl();
        UserServiceImpl userService = new UserServiceImpl();

        userService.setUserDao(userDao);
        List<Users> usersList = userService.getUserList();
        request.setAttribute("usersList",usersList);
//        System.out.println("+++++++++++++");
        request.getRequestDispatcher("/readerManagement.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
